package com.ljmin;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;


public class MySocket {

	public static void main(String[] args) throws Exception{
		ServerSocket server = new ServerSocket(8765);
		System.out.println("dddddddddd");
		Socket client = server.accept();
		InputStream in = client.getInputStream();
		OutputStream out = client.getOutputStream();
		StringBuffer sb = new StringBuffer();
		byte [] data = new byte[1024];
		int count = -1;
		while((count = in.read(data, 0, 1024)) != -1){
			sb.append(new String(data));
			out.write(data, 0, count);
		}
		System.out.println(sb);
		in.close();
		out.close();
		client.close();
		server.close();
	}
}
